var mongoose = require('../mongodb.js'), Schema = mongoose.Schema;
import mongoosePaginate from 'mongoose-paginate';
import autoIncrement from 'mongoose-auto-increment';

/**
 * 标签信息
 */
var TagsSchema = new Schema({
	name: { type: String, required: true, validate: /\S+/ },

	description: String,

	create_at: { type: Date, default: Date.now() },

	update_at: { type: Date, default: Date.now() },

	sort: { type: Number, default: 0 }
});

TagsSchema.set('toObject', { getters: true });

TagsSchema.plugin(mongoosePaginate);

TagsSchema.plugin(autoIncrement.plugin, {
	model: 'Tags',
	field: 'id',
	startAt: 1,
	incrementBy: 1
});

module.exports = mongoose.model('Tags', TagsSchema);